layui.use(['jquery', 'febs', 'table', 'form', 'fileUpload', 'commonJS', 'formSelects', 'validate'], function () {
    var $ = layui.$,
        febs = layui.febs,
        layer = layui.layer,
        form = layui.form,
        $view = $('#scheduleDialog'),
        $modify = $view.find('#modify'),
        $transfor = $view.find('#transfor'),
        $detail = $view.find('#detail'),
        $delete = $view.find('#delete'),
        $taskcode = $view.find('#taskcode'),
        validate = layui.validate;
    form.verify(validate);
    form.render();

    $modify.on('click', function () {
        febs.modal.open('修改排期', 'schedule/update/' + taskcodeData + "?type=edit", {
            area: $(window).width() <= 750 ? ['90%', '90%'] : ['80%', '90%'],
            btn: ['保存', '保存并提交'],
            offset: ['5px', '5px'],
            yes: function (index, layero) {
                $('#task-edit').find('#save').trigger('click');
                var startdate = $(layero).find('#planStartdate').val();
                var enddate = $(layero).find('#planEnddate').val();
                var taskCode = $(layero).find('#taskCode').val();
                var testDay = $(layero).find('#testDay').val();
                var obj = {
                    type: 'modify',
                    taskCode: taskCode,
                    startdate: startdate,
                    enddate: enddate,
                    testDay: testDay,
                };
                setTask(obj);
                layer.close(index);
            },
            btn2: function (index, layero) {
                $('#task-edit').find('#submit').trigger('click');
                layer.close(index);
            }, success: function (index, layero) {
            }, data: {},
        });
    });


    $transfor.on('click', function () {
        var task = {};
        task.taskCode = taskcodeData;
        layer.msg($taskcode.val());
    });

    form.on('submit(edit-form-detail)', function () {
        febs.modal.open('查看排期', 'schedule/update/' + taskcodeData + "?type=detail", {
            area: $(window).width() <= 750 ? ['90%', '90%'] : ['80%', '90%'],
            btn: ['关闭'],
            offset: ['5px', '5px'],
            yes: function (index, layero) {
                layer.close(index);
            },
            btn2: function (index, layero) {

            }, cancel: function () {

            }, data: {},
        });
    });

    $delete.on('click', function () {
        febs.modal.confirm('删除排期', '确定删除所选排期数据？', function () {
            febs.get(ctx + 'schedule/delete/' + taskcodeData, null, function () {
                febs.alert.success('删除排期任务成功');
                //将排期数据移至中间站
            });

        });
    });



});